<template>
	<view class="wrap" @tap="goto(item.id)">
		<image class="img" :src="item.pic" ></image>
		<p class="title">{{item.title}}</p>
		<button type="warn" @tap.stop="del(item.id)">删除</button>
		<!-- bindtap   catchtap -->
	</view>
</template>

<script>
	export default {
		name:"mycart",
		props:{
			item: Object
		},
		data() {
			return {
				
			};
		},
		methods:{
			goto(id){
				// 跳转到普通页面
				// id 传递
				uni.navigateTo({
					url:"/pages/detail/detail?id=" + id
				})
			},
			del(id){
				console.log(id);
				// 子组件id 发送到父组件中
				this.$emit('del' , id);
			}
		}
		
		
	}
</script>

<style lang="scss">
	.wrap{
		width: 49%;
		border: 2rpx solid #ccc;
		padding: 10rpx;
		box-sizing: border-box;
		margin-top: 10rpx;
		.img{
			width: 100%;
			height: 200rpx;
		}
		.title{
			// 单行显示省略号
			width: 100%;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
	}

</style>